﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core.EntryType;
using Cofe.Core.Implements;

namespace Cofe.Core.Defines.Properties
{
    public class CachePropertiesExpressionDefinitions : PropertyExpressionDefinitionBase<CacheProperties>
    {
        public CachePropertiesExpressionDefinitions()
        {
            registerPropertyExpression(CacheProperties.SupportedProperties, e => e.DatabaseEntry.SupportedProperties);
            registerPropertyExpression(CacheProperties.SupportedDefinitions, e => e.DatabaseEntry.SupportDefinitions);
            registerPropertyExpression(CacheProperties.OriginalType, e => e.DatabaseEntry.OriginalType);
            registerPropertyExpression(CacheProperties.LastCachedTimeUtc, e => e.DatabaseEntry.LastCacheTime);
            registerPropertyExpression(CacheProperties.LastListTimeUtc, e => e.DatabaseEntry.LastListTime);
            registerPropertyExpression(CacheProperties.Id, e => e.Id);
            registerPropertyExpression(CacheProperties.ParentId, e => e.DatabaseEntry.ParentId.Value);
        }
    }

    public class CofePropertiesExpressionDefinitions : PropertyExpressionDefinitionBase<CofeProperties>
    {
        public CofePropertiesExpressionDefinitions()
        {
            registerPropertyExpression(CofeProperties.FullParseName, e => e.DatabaseEntry.ParseName);
            registerPropertyExpression(CofeProperties.ParentParseName, e => e.DatabaseEntry.Parent.ParseName);
            registerPropertyExpression(CofeProperties.Name, e => e.DatabaseEntry.Label);
            registerPropertyExpression(CofeProperties.Label, e => e.DatabaseEntry.Label);
            registerPropertyExpression(CofeProperties.Position, e => e.DatabaseEntry.Position);
            registerPropertyExpression(CofeProperties.Type, e => e.Type);
            registerPropertyExpression(CofeProperties.CofeAttributes, e => e.CofeAttributes);
            registerPropertyExpression(CofeProperties.LastWriteTimeUtc, e => e.LastWriteTimeUtc);
            registerPropertyExpression(CofeProperties.CreationTimeUtc, e => e.CreationTimeUtc);            
        }
    }

    public class CofeItemPropertiesExpressionDefinitions : PropertyExpressionDefinitionBase<CofeItemProperties>
    {
        public CofeItemPropertiesExpressionDefinitions()
        {
            registerPropertyExpression(CofeItemProperties.Length, e => (e as CofeItemInfo).Length);
        }
    }

    public class CofeEntryTypePropertiesExpressionDefinitions : PropertyExpressionDefinitionBase<CofeEntryTypeProperties>
    {
        public CofeEntryTypePropertiesExpressionDefinitions()
        {
            registerPropertyExpression(CofeEntryTypeProperties.EntryTypeKey, e => (e as EntryTypeInfo).EntryTypeKey);            
        }
    }


}
